package com.hhkj.generator.util;

import com.hhkj.generator.util.FileReadUtil;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class TextConcatWriter {

    public static void write(File dirFile, String targetFile) throws IOException {
        File[] fileArray = dirFile.listFiles();
        List<String> contentList = new ArrayList<>();
        for (File file : fileArray) {
            List<String> oneList = FileReadUtil.readFileLine(file);

            contentList.addAll(oneList);
        }

        StringBuffer sb = new StringBuffer();

        for (String str : contentList) {
            sb.append(str + "\n");
        }

        FileWriteUtil.write(targetFile, sb.toString());
    }

    public static void main(String[] args) throws IOException {
        File file = new File("D:\\sql");
        String targetFile = "D:\\run\\sql\\order.sql";
        write(file, targetFile);
    }
}
